<template>
  <div>
    <a-drawer :visible='visible' :title='modalTitle' width='88%' @close='handleClose'>
      <a-card :bordered='false' :body-style="{padding:'0px' }">
        <f-table ref='table' size='small' :showTotal='true' rowKey='orderId' :tableColumns='columns' :operator='operator'
                 :scroll="{ x:true}" :params='queryParam' :api='api.voucherDetail' :autoLoad='false'
                 :multiple='false'>

        </f-table>
      </a-card>
    </a-drawer>
  </div>
</template>

<script>
import api from '../../../business/order/js/api'

export default {
  name: 'UserAccount',
  components: {},
  data() {

    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),

      visible: false,
      title: '单据详情列表',
      orderNo: '',
      //列表初始化查询参数
      queryParam: {
        handlerName: ''
      },
      // 表头
      columns: [
        {
          title: '单据日期',
          align: 'center',
          dataIndex: 'orderDate',
          width: '120px'
        },
        {
          title: '单位名称',
          align: 'left',
          dataIndex: 'companyName',
          ellipsis: true,
          width: '200px'
        },
        {
          title: '部门名称',
          align: 'center',
          dataIndex: 'deptName',
          width: '120px'
        },
        {
          title: '业务员',
          align: 'center',
          dataIndex: 'saleManName',
          width: '100px'
        },
        {
          title: '商品编码',
          align: 'center',
          dataIndex: 'productCode',
          width: '100px'
        },
        {
          title: '商品名称',
          align: 'center',
          dataIndex: 'productName',
          ellipsis: true,
          width: '200px'
        },
        {
          title: '规格',
          align: 'center',
          dataIndex: 'productSpecs',
          ellipsis: true,
          width: '200px'
        },
        {
          title: '批号',
          align: 'center',
          dataIndex: 'productBatch',
          width: '80px'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'productNum',
          width: '50px'
        },
        {
          title: '含税单价',
          align: 'center',
          dataIndex: 'productPrice',
          width: '80px'
        },
        {
          title: '含税金额',
          align: 'center',
          needTotal:true,
          fixed: "right",
          dataIndex: 'productSaleAmount',
          width: '80px'
        }
      ],
      operator: operator
    }
  },
  computed: {
    modalTitle: function() {
      return this.orderNo + '-' + this.title
    }
  },
  created() {

  },
  methods: {
    updateOrder(data) {
      console.log('data---', data)
      this.http.post(this, {
        url: this.api.voucher.updateOrder,
        data: {
          orderType: data.orderType,
          orderNo: data.orderNo
        },
        success(me, data) {
          me.$message.success('操作成功')
          me.$refs.table.refresh(true)
        }
      })
    },
    handleShow(data) {
      this.orderNo = ''
      this.visible = true
      this.orderNo = data.orderNo
      this.queryParam.orderNo = data.orderNo
      this.queryParam.orderType = data.orderType
      this.queryParam.companyCode = data.companyCode
      this.queryParam.dbName = data.dbName
      console.log('queryParam', this.queryParam)
      this.$nextTick(()=>{
        this.$refs.table.refresh(true)
      })
    },
    handleClose() {
      this.visible = false
    }
  }
}
</script>
